<template>
  <div id="">
    <van-nav-bar
      :title="comment.reply_count ? comment.reply_count + '条回复' : '暂无回复'"
    >
      <template #left>
        <van-icon @click="$emit('closeReply')" name="cross" />
      </template>
    </van-nav-bar>
    <div class="scroll_center">
      <CommentItem :row="comment" />
      <van-cell title="全部回复" />
      <CommentList type="c" :source="comment.com_id" :list="list" />
    </div>
    <div class="post-warp">
      <van-button @click="isShowReplyPost = true" round>评论</van-button>
    </div>
    <van-popup v-model="isShowReplyPost" position="bottom">
      <CommentPost @onPostSuccess="onClickReply" :target="comment.com_id" :art_id="$route.params.articleId" />
    </van-popup>
  </div>
</template>

<script>
import CommentItem from '@/components/CommentItem.vue'
import CommentList from '@/components/commentList.vue'
import CommentPost from './commentPost'
export default {
  name: 'CommentReply',
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  components: {
    CommentItem,
    CommentList,
    CommentPost
  },
  data () {
    return {
      list: [],
      isShowReplyPost: false
    }
  },

  // 定义方法
  methods: {
    onClickReply (obj) {
      this.isShowReplyPost = false
      this.list.unshift(obj)
    }
  }
}
</script>

<style scoped lang="less">
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  .van-button {
    width: 640px;
    height: 80px;
    background: #eee;
  }
}
.scroll_center {
  position: absolute;
  top: 90px;
  bottom: 102px;
  width: 100%;
  overflow-y: scroll;
}
</style>
